package android.slc.user.ui;

import android.app.Application;
import android.slc.appbase.vm.AppBaseViewModel;
import android.slc.user.R;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;

/**
 * @author slc
 * @date 2020-07-28 15:48
 */
public class EditPassWordVm extends AppBaseViewModel {
    public final ObservableField<String> oldPasswordOf = new ObservableField<>();
    public final ObservableField<String> newPasswordOf = new ObservableField<>();
    public final ObservableField<String> verifyNewPasswordOf = new ObservableField<>();

    public EditPassWordVm(@NonNull Application application) {
        super(application);
    }

    public void editPassWord() {
        if (StringUtils.isEmpty(oldPasswordOf.get())
                || StringUtils.isEmpty(newPasswordOf.get())
                || StringUtils.isEmpty(verifyNewPasswordOf.get())) {
            ToastUtils.showShort(R.string.label_content_cannot_be_empty_blank);
        } else if (!StringUtils.equals(newPasswordOf.get(), verifyNewPasswordOf.get())) {
            ToastUtils.showShort(R.string.user_label_verify_new_password_error);
        } else {
            //TODO 调用修改密码接口
        }
    }
}
